<!--
  ~ MIT License
  ~
  ~ Copyright (c) 2021-2022 yangrunkang
  ~
  ~ Author: yangrunkang
  ~ Email: yangrunkang53@gmail.com
  ~
  ~ Permission is hereby granted, free of charge, to any person obtaining a copy
  ~ of this software and associated documentation files (the "Software"), to deal
  ~ in the Software without restriction, including without limitation the rights
  ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  ~ copies of the Software, and to permit persons to whom the Software is
  ~ furnished to do so, subject to the following conditions:
  ~
  ~ The above copyright notice and this permission notice shall be included in all
  ~ copies or substantial portions of the Software.
  ~
  ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  ~ SOFTWARE.
  -->

<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-4.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<body>

<div th:fragment="comment_box(targetId,source,text)">
    <div>
        <div class="text-center" id="comment_loading">
            <div class="spinner-grow text-primary" role="status"></div>
            <p class="text-black-50">评论框加载中...</p>
        </div>
        <div th:replace="fragments/editor::upupor-editor-progress"></div>
        <div id="vcr_editor" style="height: 300px; overflow:hidden"></div>
        <input type="hidden" id="reply_to_user" />
        <div id="comment_btn_group" style="display: none">
            <button class="btn rounded-3 bg-gradient btn-primary btn-sm btn-cv-comment my-2" th:onclick="comment([[${targetId}]],[[${source}]],[[${text}]])">[[${text}]]</button>
            <button class="btn rounded-3 bg-gradient btn-secondary btn-sm my-2" th:onclick="cancel()">清空</button>
            <div class="btn rounded-3 bg-gradient btn-link cv-link btn-sm my-2" th:include="fragments/common::markdown"></div>
        </div>
    </div>
</div>


<div th:fragment="commentList(commentList,paginationHtml,total,fromProfile,targetUserId)">
    <div th:class="${fromProfile}?'':'card card-body shadow-sm border-bottom border-2 border-top-0 border-start border-end-0 p-2 my-2'">
        <div th:if="${#lists.isEmpty(commentList)}" th:include="fragments/index::empty_content"></div>
        <div th:if="!${#lists.isEmpty(commentList)}">
            <div class="border-bottom mb-2" th:if="!${fromProfile}">
                <span class="lead">评论<span class="badge bg-gradient rounded-3 fw-normal bg-warning text-dark ms-1" th:text="${total}"></span></span>
            </div>
            <div class="list-group list-group-flush">
                <div class="d-flex align-items-top list-group-item p-1 mt-1" th:if="${comment.commentId != 'google-ad-feed'}" th:each="comment : ${commentList}">
                    <a class="cv-link" th:href="'/profile/'+${comment.member.userId}+'/content'">
                        <img th:data-src="${comment.member.via}" class="lazyload align-self-center me-1 mb-1 cv-icon-50 img rounded" th:alt="${comment.member.userName}"/>
                    </a>
                    <div class="flex-grow-1" style="overflow:hidden;">
                        <div class="mt-0">
                            <a class="text-black-50 cv-link fw-bold" th:href="'/profile/'+${comment.member.userId}+'/content'">
                                [[${comment.member.userName}]] <span class="badge rounded-3 fw-normal" style="border: 1px solid #DAEDE4;color: #3f7b5a;background-color: #EFF7ED;" th:if="${comment.member.userId == targetUserId}">楼主</span>
                            </a>
                            <div class="float-end text-black-50 small">
                                <span class="d-none d-sm-block float-start text-black-50 ">[[${comment.createDateDiff}]]&nbsp;·&nbsp;</span>
                                <span style="cursor: pointer" th:if="${session?.cv_user_id}" th:onclick="renderReplayUserName([[${comment.member.userName}]],[[${comment.member.userId}]])">回复<i class="bi bi-reply-fill"></i></span>
                                <span style="cursor: pointer" th:if="!${session?.cv_user_id}" th:onclick="window.location.href='/login?back=' + window.location.pathname">回复<i class="bi bi-reply-fill"></i></span>
                                ·&nbsp;<span class="badge bg-gradient bg-light text-black-50" th:text="${comment.floorNum} + '#'"></span>
                            </div>
                        </div>
                        <article class="cherry-markdown" th:utext="${comment.commentContent}">评论内容</article>
                    </div>
                </div>
            </div>
            <div>
                <div class="mt-2 float-end"
                     th:if="!${#strings.isEmpty(paginationHtml)}"
                     th:utext="${paginationHtml}"> </div>
            </div>
        </div>
    </div>
</div>
</body>
</html>
